package org.net5ijy.commons.http.response;

import java.io.File;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * FileResponseHolder类
 *
 * @author xuguofeng
 * @date 2020/7/13 12:13
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class FileResponseHolder extends ResponseHolder {

  private File file;

  public FileResponseHolder() {
    super();
  }

  @Override
  public String toString() {

    StringBuilder sb = new StringBuilder("HtmlResponseHolder: ");

    // 拼接响应状态码
    sb.append("StatusCode: ")
        .append(getStatusCode())
        .append("\n")
        // 拼接content-type
        .append("Content-Type: ")
        .append(getContentType())
        .append("\n")
        // 拼接响应头
        .append("Headers: ")
        .append(getHeaders())
        .append("\n")
        // 拼接Cookie
        .append("Cookies: ")
        .append(getCookies())
        .append("\n")
        // 拼接html内容
        .append("File: ")
        .append(this.file.getAbsolutePath());

    return sb.toString();
  }
}
